# define PI 3.1415925

class Cone3d {
  int ang;
  int tip_pos[3];
 public:
  Cone3d(int * tip,int angle);
  bool point_in(int * point);
  bool walk_in(Walk walk1);
};

Cone3d::Cone3d(int * tip,int angle) {
  int i;
  ang=angle;
  for (i=0;i<3;i++) {
    tip_pos[i]=tip[i];
  }
}

bool Cone3d::point_in(int * point) {
  int i;
  float R,x,y,z,ang1;
  x=point[0]-tip_pos[0];
  y=point[1]-tip_pos[1];
  z=point[2]-tip_pos[2];
  R=sqrt(x*x+y*y);
  if ((z<1) && (z>-1)) {
    if (R<1) return 0;
    else ang1=PI/2;
  }
  else ang1=atan(R/z);
  if (ang1<0) ang1=ang1+PI;
  //cout << "R= " << R << " ang is: " << ang1*180/PI << "\n";
  if (ang1>ang) return 0;
  else return 1;
}

bool Cone3d::walk_in(Walk walk1) {
  int pos[3];
  int i,n;
  n=walk1.get_length();
  for (i=0;i<n+1;i++) {
    walk1.get_pos(i,pos);
    if (point_in(pos)==0) return 0;
  }
  return 1;
}
